package com.hopu.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author YwaiX
 * @since 2024-09-12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_staff")
public class Staff implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 工号
     */
    @TableField("staff_no")
    @Length(message = "工号不低于6位", min = 6, groups = Save.class)
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9]{5,9}$",message = "格式不正确",groups = Save.class)
    @NotBlank(message = "工号不能为空",groups = Save.class)
    private String staffNo;

    /**
     * 密码
     */
    @TableField("password")
    @Length(message = "密码不低于4位", min = 4, groups = Save.class)
    @NotBlank(message = "密码不能为空",groups = Save.class)
    private String password;

    /**
     * 性别，1男；0女
     */
    @TableField("gender")
    @NotBlank(message = "性别不能为空",groups = Save.class)
    private Integer gender;

    /**
     * 员工真实姓名
     */
    @TableField("real_name")
    @Length(message = "真实姓名不低于2位", min = 2, groups = Save.class)
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]{2,10}$",message = "格式不正确",groups = Save.class)
    @NotBlank(message = "真实姓名不能为空",groups = Save.class)
    private String realName;

    /**
     * 身份证号
     */
    @TableField("id_card")
    @NotBlank(message = "身份证号不能为空",groups = Save.class)
    @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)",message = "格式不正确", groups = Save.class)
    private String idCard;

    /**
     * 出生日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @NotBlank(message = "出生日期不能为空",groups = Save.class)
    @TableField("date_of_birth")
    private LocalDate dateOfBirth;

    /**
     * 头像
     */
    @TableField("photo_url")
    private String photoUrl;

    /**
     * 手机号码
     */
    @TableField("phone")
    @NotBlank(message = "手机号码不能为空",groups = Save.class)
    @Pattern(regexp = "^1\\d{10}$",message = "格式不正确",groups = Save.class)
    private String phone;

    /**
     * 教育背景
     */
    @TableField("education_background")
    private String educationBackground;

    /**
     * 组织id
     */
    @TableField("organization_id")
    @NotBlank(message = "组织id不能为空",groups = Save.class)
    private Integer organizationId;

    /**
     * 入职日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField("join_date")
    private LocalDate joinDate;

    /**
     * 离职日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField("leave_date")
    private LocalDate leaveDate;

    /**
     * 岗位名称
     */
    @TableField("job_name")
    @NotBlank(message = "岗位名称不能为空",groups = Save.class)
    private String jobName;

    /**
     * 薪资，单位RMB
     */
    @TableField("salary")
    @NotBlank(message = "薪资不能为空",groups = Save.class)
    private BigDecimal salary;

    /**
     * 创建人
     */
    @TableField("create_by")
    @NotBlank(message = "创建人不能为空",groups = Save.class)
    private Integer createBy;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 修改人
     */
    @TableField("update_by")
    private Integer updateBy;

    /**
     * 修改时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("update_time")
    private LocalDateTime updateTime;

    /**
     * 状态，1启用；0禁用
     */
    @TableField("status")
    private Integer status;

    /**
     * 是否首次登陆
     */
    @TableField("is_first_login")
    private Integer isFirstLogin;


}
